﻿using UnityEngine;
using System.Collections;

public class Menu : MonoBehaviour 
{
	public Transform bolinha;
	public AudioSource changeSound;

	public MovieTexture movie;

	private float movieTime;

	private bool tocandoVideo = false;
	// Use this for initialization
	void Start () 
	{
		movie.Stop ();
	}

	// Update is called once per frame
	void Update () 
	{
		if (Input.GetKeyDown("down"))
		{
			if (bolinha.position == new Vector3(-5.4f, -0.4f, 0f))
			{
				bolinha.position = new Vector3(-5.4f, -2.4f, 0f);
				if (!changeSound.isPlaying)
					changeSound.Play();
			}
			else if (bolinha.position == new Vector3(-5.4f, -2.4f, 0f))
			{
				bolinha.position = new Vector3(-5.4f, -4.0f, 0f);
				if (!changeSound.isPlaying)
					changeSound.Play();
			}
			else if (bolinha.position == new Vector3(-5.4f, -4.0f, 0f))
			{
				bolinha.position = new Vector3(-5.4f, -0.4f, 0f);
				if (!changeSound.isPlaying)
					changeSound.Play();
			}
		}
		else if (Input.GetKeyDown("up"))	
		{
			if (bolinha.position == new Vector3(-5.4f, -0.4f, 0f))
			{
				bolinha.position = new Vector3(-5.4f, -4.0f, 0f);
				if (!changeSound.isPlaying)
					changeSound.Play();
			}
			else if (bolinha.position == new Vector3(-5.4f, -2.4f, 0f))
			{
				bolinha.position = new Vector3(-5.4f, -0.4f, 0f);
				if (!changeSound.isPlaying)
					changeSound.Play();
			}
			else if (bolinha.position == new Vector3(-5.4f, -4.0f, 0f))
			{
				bolinha.position = new Vector3(-5.4f, -2.4f, 0f);
				if (!changeSound.isPlaying)
					changeSound.Play();
			}
		}


		if (bolinha.position == new Vector3(-5.4f, -4.0f, 0f) && Input.GetButton("Jump")) 
		{
			Application.LoadLevel(2);
		}

		if (bolinha.position == new Vector3(-5.4f, -2.4f, 0f) && Input.GetButton("Jump"))
		{
			Application.LoadLevel(3);
		}

		if (bolinha.position == new Vector3(-5.4f, -0.4f, 0f) && Input.GetButton("Jump")) 
		{
			//Application.LoadLevel(1);
			transform.position = new Vector3 (0,0, -1f);
			tocandoVideo = true;
			movie.Play();
		}
		if (tocandoVideo)
		{
			movieTime += Time.deltaTime;
			if (movieTime > 28.0f)
			{
				Application.LoadLevel(1);
			}

		}

	}
}
